export type QuestionType =
  | "text"
  | "number"
  | "single-select"
  | "multi-select"
  | "date"
  | "single-slider"
  | "double-slider"
  | "location"
  | "composite";

export interface Option {
  value: string | number;
  label: string;
  hasInput?: boolean;
  isInputGroup?: boolean;
  maxInputCount?: number;
  placeholder?: string;
}

export interface CompositeField {
  id: string;
  type: "text" | "number" | "single-select" | "multi-select" | "location";
  label?: string;
  placeholder?: string;
  options?: Option[];
  required?: boolean;
  isInputGroup?: boolean;
  maxInputCount?: number;
  multiLine?: boolean;
  defaultValue?: string | number | string[] | number[];
  dependsOn?: {
    questionId: string;
    value: string | string[];
  };
}

export interface QuestionConfig {
  id: string;
  type: QuestionType;
  label: string;
  required?: boolean;
  options?: Option[];
  min?: number;
  max?: number;
  step?: number;
  placeholder?: string;
  multiLine?: boolean;
  defaultValue?: string | number | string[] | number[] | [number, number];
  compositeFields?: CompositeField[];
  dependsOn?: {
    questionId: string;
    value: string | string[];
  };
}

export interface FormSection {
  title: string;
  questions: QuestionConfig[];
}

export const formConfig: FormSection[] = [
  {
    title: "关于本人",
    questions: [
      {
        id: "contactInfo",
        type: "composite",
        label: "联系方式",
        required: true,
        compositeFields: [
          {
            id: "contactType",
            type: "single-select",
            required: true,
            defaultValue: "wechatId",
            options: [
              { value: "redBookId", label: "小红书号" },
              { value: "wechatId", label: "微信号" },
            ],
          },
          {
            id: "contactValue",
            type: "text",
            placeholder: "请输入联系方式",
            required: true,
          },
        ],
      },
      {
        id: "nickname",
        type: "text",
        label: "昵称",
        required: true,
        placeholder: "请输入昵称",
      },
      {
        id: "gender",
        type: "single-select",
        label: "性别",
        required: true,
        defaultValue: "1",
        options: [
          { value: "1", label: "男" },
          { value: "0", label: "女" },
        ],
      },
      {
        id: "birthDate",
        type: "date",
        label: "出生日期",
        required: true,
      },
      {
        id: "height",
        type: "single-slider",
        label: "净身高（cm）",
        required: true,
        min: 140,
        max: 200,
        step: 1,
        defaultValue: 170,
      },
      {
        id: "weight",
        type: "single-slider",
        label: "体重（kg）",
        required: true,
        min: 30,
        max: 150,
        step: 0.5,
        defaultValue: 60,
      },
      {
        id: "healthStatus",
        type: "single-select",
        label: "本人健康情况",
        required: true,
        defaultValue: "healthy",
        options: [
          { value: "healthy", label: "健康" },
          {
            value: "chronicDisease",
            label: "患慢性病（需长期管理，如高血压、糖尿病等）",
          },
          {
            value: "majorDisease",
            label: "患重大疾病（需持续治疗或康复，如癌症、心脑血管疾病等）",
          },
          {
            value: "disabled",
            label: "残疾（包含肢体、视力、听力等方面的残疾）",
          },
        ],
      },
      {
        id: "hometown",
        type: "location",
        label: "籍贯",
        required: true,
      },
      {
        id: "currentLocation",
        type: "composite",
        label: "现居地",
        required: true,
        compositeFields: [
          {
            id: "locationType",
            type: "single-select",
            required: true,
            options: [
              { value: "domestic", label: "国内" },
              { value: "international", label: "国外" },
            ],
          },
          {
            id: "domesticLocation",
            type: "location",
            required: true,
            dependsOn: {
              questionId: "locationType",
              value: "domestic",
            },
          },
          {
            id: "internationalLocation",
            type: "text",
            placeholder: "请输入国家名称",
            required: true,
            dependsOn: {
              questionId: "locationType",
              value: "international",
            },
          },
        ],
      },
      {
        id: "maritalStatus",
        type: "single-select",
        label: "婚姻状态",
        required: true,
        options: [
          { value: "neverMarriedNoKids", label: "未婚未育" },
          { value: "neverMarriedWithKids", label: "未婚已育" },
          { value: "divorcedNoKids", label: "离异未育" },
          { value: "divorcedWithKids", label: "离异已育" },
          { value: "widowedNoKids", label: "丧偶未育" },
          { value: "widowedWithKids", label: "丧偶已育" },
        ],
      },
      {
        id: "education",
        type: "single-select",
        label: "学历",
        required: true,
        options: [
          { value: "highSchoolOrLess", label: "高中及以下" },
          { value: "associate", label: "专科" },
          { value: "bachelor", label: "本科" },
          { value: "master", label: "硕士" },
          { value: "doctor", label: "博士" },
        ],
      },
      {
        id: "schoolName",
        type: "text",
        label: "学校名称",
        placeholder: "请输入学校名称",
      },
      {
        id: "isOnlyChild",
        type: "single-select",
        label: "是否独生子女",
        required: true,
        options: [
          { value: "yes", label: "是" },
          { value: "no", label: "否" },
        ],
      },
      {
        id: "housePlan",
        type: "single-select",
        label: "未来购房计划",
        required: true,
        options: [
          { value: "hasHouseWithLoan", label: "已有房（有贷款）" },
          { value: "hasHouseNoLoan", label: "已有房（无贷款）" },
          { value: "canBuyHouse", label: "暂无房，但有能力在现居地购房" },
          { value: "noPlans", label: "暂不考虑" },
        ],
      },
      {
        id: "carPlan",
        type: "single-select",
        label: "未来购车计划",
        required: true,
        options: [
          { value: "hasCarWithLoan", label: "已有车（有贷款）" },
          { value: "hasCarNoLoan", label: "已有车（无贷款）" },
          { value: "canBuyCar", label: "暂无车，但有能力在现居地购车" },
          { value: "noPlans", label: "暂不考虑" },
        ],
      },
      {
        id: "annualIncome",
        type: "single-select",
        label: "年收入（税前）",
        required: true,
        options: [
          { value: "below5w", label: "5万以下" },
          { value: "5w-10w", label: "5万-10万" },
          { value: "10w-20w", label: "10万-20万" },
          { value: "20w-30w", label: "20万-30万" },
          { value: "30w-50w", label: "30万-50万" },
          { value: "50w-100w", label: "50万-100万" },
          { value: "above100w", label: "100万以上" },
          { value: "none", label: "暂无" },
        ],
      },
      {
        id: "industryInfo",
        type: "composite",
        label: "所属行业",
        required: true,
        compositeFields: [
          {
            id: "industry",
            type: "single-select",
            required: true,
            options: [
              { value: "stateOwned", label: "国企/央企" },
              { value: "institution", label: "事业单位" },
              { value: "civilServant", label: "公务员" },
              { value: "itInternet", label: "互联网/IT" },
              { value: "financeLaw", label: "金融/法律" },
              { value: "educationResearch", label: "教育/科研" },
              { value: "healthcareMedical", label: "医疗/健康" },
              { value: "freelancerEntrepreneur", label: "自由职业/创业" },
              { value: "manufacturingElectronics", label: "电子电器/制造业" },
              { value: "chemicalNewMaterials", label: "化工/新材料" },
              { value: "tradeProcurement", label: "商贸/采购" },
              { value: "unemployed", label: "待业" },
              { value: "student", label: "学生" },
              { value: "other", label: "其他" },
            ],
          },
          {
            id: "customIndustry",
            type: "text",
            placeholder: "请输入行业名称",
            required: true,
            isInputGroup: true,
            maxInputCount: 3,
            dependsOn: {
              questionId: "industry",
              value: "other",
            },
          },
        ],
      },
      {
        id: "studentGrade",
        type: "single-select",
        label: "当前年级",
        dependsOn: {
          questionId: "industryInfo.industry",
          value: "student",
        },
        options: [
          { value: "undergrad1", label: "大一" },
          { value: "undergrad2", label: "大二" },
          { value: "undergrad3", label: "大三" },
          { value: "undergrad4", label: "大四" },
          { value: "masters1", label: "研一" },
          { value: "masters2", label: "研二" },
          { value: "masters3", label: "研三" },
          { value: "phd1", label: "博一" },
          { value: "phd2to5", label: "博二至博五" },
        ],
      },
      {
        id: "major",
        type: "text",
        label: "专业名称",
        dependsOn: {
          questionId: "industryInfo.industry",
          value: "student",
        },
        placeholder: "请输入专业名称",
      },
      {
        id: "marriagePlan",
        type: "single-select",
        label: "未来3年婚恋计划",
        required: true,
        options: [
          { value: "within1year", label: "希望1年内结婚" },
          { value: "within2to3years", label: "希望2-3年内结婚" },
          { value: "whenAppropriate", label: "随缘，遇到合适再考虑" },
          { value: "noPlans", label: "暂无明确计划" },
        ],
      },
      {
        id: "parentsMarriage",
        type: "single-select",
        label: "父母婚姻状态",
        required: true,
        options: [
          { value: "bothLivingTogether", label: "双亲健在且同住" },
          { value: "bothLivingSeparate", label: "双亲健在分居" },
          { value: "divorcedSingleParent", label: "离异单亲" },
          { value: "widowedSingleParent", label: "丧偶单亲" },
        ],
      },
      {
        id: "parentsHealthInfo",
        type: "composite",
        label: "父母健康情况",
        compositeFields: [
          {
            id: "parentsHealth",
            type: "single-select",
            options: [
              { value: "bothHealthy", label: "双方均健康（无慢性或重大疾病）" },
              {
                value: "oneHealthyOneChronic",
                label: "一方健康，一方有慢性病（如高血压、糖尿病等需长期管理）",
              },
              {
                value: "oneHealthyOneMajor",
                label: "一方健康，一方有重大疾病（如癌症、心脑血管疾病等）",
              },
              { value: "bothChronic", label: "双方均有慢性病" },
              { value: "bothMajor", label: "双方均有重大疾病" },
              { value: "other", label: "其他（如父母已故/残疾/精神疾病等）" },
            ],
          },
          {
            id: "customParentsHealth",
            type: "text",
            placeholder: "请说明具体情况",
            multiLine: true,
            dependsOn: {
              questionId: "parentsHealth",
              value: "other",
            },
          },
        ],
      },
      {
        id: "liveWithParents",
        type: "single-select",
        label: "是否介意婚后与父母同住",
        required: true,
        options: [
          { value: "mind", label: "介意" },
          { value: "dontMind", label: "不介意" },
        ],
      },
      {
        id: "hobbiesInfo",
        type: "composite",
        label: "兴趣爱好",
        compositeFields: [
          {
            id: "hobbies",
            type: "multi-select",
            options: [
              { value: "sports", label: "运动健身" },
              { value: "travel", label: "旅行、徒步" },
              { value: "reading", label: "阅读、科学、历史、语言、哲学等" },
              { value: "music", label: "音乐、演唱会、音乐会等" },
              { value: "movies", label: "电影、追剧" },
              { value: "photography", label: "摄影" },
              { value: "art", label: "艺术创作" },
              { value: "gaming", label: "电子游戏" },
              { value: "boardGames", label: "桌游" },
              { value: "cooking", label: "烹饪" },
              { value: "escape", label: "剧本杀、密室逃脱" },
              { value: "handcraft", label: "手工、DIY" },
              { value: "programming", label: "编程、写作" },
              { value: "other", label: "其他" },
            ],
          },
          {
            id: "customHobbies",
            type: "text",
            placeholder: "请输入爱好",
            isInputGroup: true,
            maxInputCount: 5,
            dependsOn: {
              questionId: "hobbies",
              value: "other",
            },
          },
        ],
      },
      {
        id: "petPreference",
        type: "single-select",
        label: "宠物意愿",
        options: [
          { value: "hasPet", label: "已养宠物" },
          { value: "noPet", label: "不养/不喜欢" },
          { value: "wantPet", label: "希望共同养宠物" },
          { value: "acceptPet", label: "接受对方养宠物" },
          { value: "neutral", label: "无所谓" },
        ],
      },
      {
        id: "isDink",
        type: "single-select",
        label: "是否丁克",
        required: true,
        options: [
          { value: "yes", label: "是" },
          { value: "no", label: "否" },
        ],
      },
      {
        id: "hasReligion",
        type: "single-select",
        label: "有无宗教信仰",
        options: [
          { value: "yes", label: "是" },
          { value: "no", label: "无" },
        ],
      },
      {
        id: "smokingDrinking",
        type: "single-select",
        label: "吸烟/饮酒情况",
        required: true,
        options: [
          { value: "both", label: "既吸烟又饮酒" },
          { value: "onlySmoking", label: "只吸烟不饮酒" },
          { value: "onlyDrinking", label: "只饮酒不吸烟" },
          { value: "neither", label: "不吸烟不饮酒" },
        ],
      },
      {
        id: "messageToMatch",
        type: "text",
        label: "给对方的一句话",
        placeholder: "匹配后对方可见",
        multiLine: true,
      },
    ],
  },
  {
    title: "关于期望对象",
    questions: [
      {
        id: "expectedAgeRange",
        type: "double-slider",
        label: "期望年龄范围",
        required: true,
        min: 18,
        max: 50,
        step: 1,
        defaultValue: [25, 35],
      },
      {
        id: "expectedHeightRange",
        type: "double-slider",
        label: "期望身高范围",
        required: true,
        min: 140,
        max: 200,
        step: 1,
      },
      {
        id: "expectedWeightRange",
        type: "double-slider",
        label: "期望体重范围",
        required: true,
        min: 40,
        max: 100,
        step: 0.5,
      },
      {
        id: "expectedEducation",
        type: "single-select",
        label: "期望学历",
        required: true,
        options: [
          { value: "highSchoolAndAbove", label: "高中及以上" },
          { value: "associateAndAbove", label: "专科及以上" },
          { value: "bachelorAndAbove", label: "本科及以上" },
          { value: "masterAndAbove", label: "硕士及以上" },
          { value: "doctorAndAbove", label: "博士及以上" },
          { value: "noRequirement", label: "不限" },
        ],
      },
      {
        id: "expectedMaritalStatus",
        type: "single-select",
        label: "期待对方婚姻状态",
        required: true,
        options: [
          { value: "neverMarriedNoKids", label: "未婚未育" },
          { value: "neverMarriedWithKids", label: "未婚已育" },
          { value: "divorcedNoKids", label: "离异未育" },
          { value: "divorcedWithKids", label: "离异已育" },
          { value: "widowedNoKids", label: "丧偶未育" },
          { value: "widowedWithKids", label: "丧偶已育" },
          { value: "noRequirement", label: "不限" },
        ],
      },
      {
        id: "expectedIncome",
        type: "single-select",
        label: "期望对方年收入（税前）",
        required: true,
        options: [
          { value: "below5w", label: "5万以下" },
          { value: "5w-10w", label: "5万-10万" },
          { value: "10w-20w", label: "10万-20万" },
          { value: "20w-30w", label: "20万-30万" },
          { value: "30w-50w", label: "30万-50万" },
          { value: "50w-100w", label: "50万-100万" },
          { value: "above100w", label: "100万以上" },
          { value: "noRequirement", label: "不限" },
        ],
      },
      {
        id: "acceptSingleParent",
        type: "single-select",
        label: "能否接受对方单亲家庭",
        required: true,
        options: [
          { value: "yes", label: "能" },
          { value: "no", label: "不能" },
          { value: "noRequirement", label: "不限" },
        ],
      },
      {
        id: "mindLivingWithPartnerParents",
        type: "single-select",
        label: "是否介意与对方父母同住",
        required: true,
        options: [
          { value: "mind", label: "介意" },
          { value: "dontMind", label: "不介意" },
        ],
      },
      {
        id: "acceptNonOnlyChild",
        type: "single-select",
        label: "能否接受非独生子女",
        required: true,
        options: [
          { value: "yes", label: "能" },
          { value: "no", label: "不能" },
          { value: "noRequirement", label: "不限" },
        ],
      },
      {
        id: "expectedMarriagePlan",
        type: "single-select",
        label: "未来3年婚恋计划",
        required: true,
        options: [
          { value: "within1year", label: "希望1年内结婚" },
          { value: "within2to3years", label: "希望2-3年内结婚" },
          { value: "whenAppropriate", label: "随缘，遇到合适再考虑" },
          { value: "noPlans", label: "暂无明确计划" },
        ],
      },
      {
        id: "expectedHouseCar",
        type: "single-select",
        label: "期望房车情况",
        required: true,
        options: [
          { value: "bothHouseCar", label: "有房有车" },
          { value: "onlyHouse", label: "有房即可" },
          { value: "onlyCar", label: "有车即可" },
          { value: "noRequirement", label: "不限" },
        ],
      },
      {
        id: "expectedLocation",
        type: "composite",
        label: "期望现居地",
        required: true,
        compositeFields: [
          {
            id: "locationType",
            type: "single-select",
            required: true,
            options: [
              { value: "sameCity", label: "同城" },
              { value: "sameProvince", label: "同省" },
              { value: "neighboringProvince", label: "本省及周边省" },
              { value: "noRequirement", label: "不限" },
              { value: "custom", label: "其他（自定义）" },
            ],
          },
          {
            id: "customLocations",
            type: "text",
            placeholder: "请输入地区名称",
            required: true,
            isInputGroup: true,
            maxInputCount: 5,
            dependsOn: {
              questionId: "locationType",
              value: "custom",
            },
          },
        ],
      },
      {
        id: "expectedIndustry",
        type: "multi-select",
        label: "期望所属行业",
        options: [
          { value: "stateOwned", label: "国企/央企" },
          { value: "institution", label: "事业单位" },
          { value: "civilServant", label: "公务员" },
          { value: "itInternet", label: "互联网/IT" },
          { value: "financeLaw", label: "金融/法律" },
          { value: "educationResearch", label: "教育/科研" },
          { value: "healthcareMedical", label: "医疗/健康" },
          { value: "freelancerEntrepreneur", label: "自由职业/创业" },
          { value: "manufacturingElectronics", label: "电子电器/制造业" },
          { value: "chemicalNewMaterials", label: "化工/新材料" },
          { value: "tradeProcurement", label: "商贸/采购" },
          { value: "unemployed", label: "待业" },
          { value: "student", label: "学生" },
        ],
      },
      {
        id: "hobbyMatchRequirement",
        type: "single-select",
        label: "兴趣爱好匹配要求",
        options: [
          { value: "atLeast3", label: "至少3项共同兴趣" },
          { value: "atLeast1", label: "至少1项共同兴趣" },
          { value: "noRequirement", label: "不限" },
        ],
      },
      {
        id: "acceptSmokingDrinking",
        type: "single-select",
        label: "是否接受对方吸烟或饮酒",
        options: [
          { value: "bothAccept", label: "接受吸烟和饮酒" },
          { value: "onlySmokingAccept", label: "仅接受吸烟" },
          { value: "onlyDrinkingAccept", label: "仅接受饮酒" },
          { value: "neitherAccept", label: "均不接受" },
        ],
      },
      {
        id: "acceptPets",
        type: "single-select",
        label: "对宠物接受情况",
        options: [
          { value: "accept", label: "接受" },
          { value: "notAccept", label: "不接受" },
          { value: "noRequirement", label: "不限" },
        ],
      },
      {
        id: "expectDink",
        type: "single-select",
        label: "是否希望对方丁克",
        options: [
          { value: "yes", label: "是" },
          { value: "no", label: "否" },
          { value: "noRequirement", label: "不限" },
        ],
      },
      {
        id: "acceptReligion",
        type: "single-select",
        label: "对宗教信仰接受情况",
        options: [
          { value: "accept", label: "接受" },
          { value: "notAccept", label: "不接受" },
          { value: "noRequirement", label: "不限" },
        ],
      },
    ],
  },
];
